package compiler;

import java.io.IOException;

import graph.*;
import org.antlr.runtime.*;

/**
 * A compiler which compiles source code and generates the corresponding graph
 *
 */

public class SourceCompiler {
	
	/**
	 * 
	 * @param file The source file to compile
	 * @return The corresponding graph
	 * @throws IOException 
	 * @throws RecognitionException 
	 */
	
	/*
	 * Note that we're using temporarily the Graph class from the jgraphT library
	 */
	public Graph getGraph(String file) throws IOException, RecognitionException
	{
		ANTLRFileStream input = new ANTLRFileStream(file);
		tinyLexer lexer = new tinyLexer(input);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		tinyParser parser = new tinyParser(tokens);
		Graph graph = parser.program();
		
		return graph;
		
	}

}
